package com.sushuo.api.service;

import java.util.LinkedList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sushuo.api.dao.OprSpecialtyDao;
import com.sushuo.base.bean.OprSpecialty;
import com.sushuo.base.bean.sql.PageData;
import com.sushuo.base.bean.sql.Sort;


@Service
public class OprSpecialtyService{

    @Autowired
    private OprSpecialtyDao oprspecialtyDao;

    public OprSpecialty getById(Integer id){
        return oprspecialtyDao.findOne(id);
    }

    public OprSpecialty save(OprSpecialty oprspecialty){
        return oprspecialtyDao.save(oprspecialty);
    }

    public void deleteById(Integer id){
        oprspecialtyDao.delete(id);
    }

    public PageData <OprSpecialty> getPage(int page, int pageSize){
        StringBuilder sb = new StringBuilder();
        sb.append("SELECT * FROM t_opr_specialty p ");
        List<Object> param = new LinkedList<>();
        return oprspecialtyDao.findPageBySql(sb.toString(), param, OprSpecialty.class, new PageData<>(page, pageSize),
            Sort.getSort("gmt_modified", Sort.Direction.DESC));
    }
}
